package com.cyt.chattlibrary.message.view;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.cyt.chattlibrary.R;
import com.cyt.chattlibrary.face.SmileyParser;
import com.cyt.chattlibrary.message.TextMessage;
import com.cyt.chattlibrary.message.model.MessageContent;

public class TextMsgView extends BaseMsgView {

    private TextView username;
    private TextView msgText;

    public TextMsgView(Context context) {
        super(context);
        View view = LayoutInflater.from(getContext()).inflate(R.layout.msg_text_view, this);
        username = view.findViewById(R.id.username);
        msgText = view.findViewById(R.id.msg_text);
    }

    @Override
    public void setContent(MessageContent msgContent) {
        TextMessage msg = (TextMessage) msgContent;
        username.setText(msg.getUserInfo().getName() + ": ");
        msgText.setText(SmileyParser.getInstance().addSmileySpans(msg.getContent(), msgText.getTextSize()));
    }
}
